package com.ruoyi.different.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.different.domain.DifferentLogging;
import com.ruoyi.different.service.IDifferentLoggingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 日志记录Controller
 * 
 * @author rocky
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/different/logging")
public class VxDifferentLoggingController extends BaseController
{
    @Autowired
    private IDifferentLoggingService differentLoggingService;

    /**
     * 查询日志记录列表
     */
    //@PreAuthorize("@ss.hasPermi('different:logging:list')")
    @GetMapping("/list/vx")
    public TableDataInfo list(DifferentLogging differentLogging)
    {
        startPage();
        List<DifferentLogging> list = differentLoggingService.selectDifferentLoggingList(differentLogging);
        return getDataTable(list);
    }

    /**
     * 导出日志记录列表
     */
   // @PreAuthorize("@ss.hasPermi('different:logging:export')")
    @Log(title = "日志记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export/vx")
    public void export(HttpServletResponse response, DifferentLogging differentLogging)
    {
        List<DifferentLogging> list = differentLoggingService.selectDifferentLoggingList(differentLogging);
        ExcelUtil<DifferentLogging> util = new ExcelUtil<DifferentLogging>(DifferentLogging.class);
        util.exportExcel(response, list, "日志记录数据");
    }

    /**
     * 获取日志记录详细信息
     */
   // @PreAuthorize("@ss.hasPermi('different:logging:query')")
    @GetMapping(value = "/vx/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(differentLoggingService.selectDifferentLoggingByLogId(logId));
    }

    /**
     * 新增日志记录
     */
  //  @PreAuthorize("@ss.hasPermi('different:logging:add')")
    @Log(title = "日志记录", businessType = BusinessType.INSERT)
    @PostMapping("/vx")
    public AjaxResult add(@RequestBody DifferentLogging differentLogging)
    {
        return toAjax(differentLoggingService.insertDifferentLogging(differentLogging));
    }

    /**
     * 修改日志记录
     */
   //@PreAuthorize("@ss.hasPermi('different:logging:edit')")
    @Log(title = "日志记录", businessType = BusinessType.UPDATE)
    @PutMapping("/vx")
    public AjaxResult edit(@RequestBody DifferentLogging differentLogging)
    {
        return toAjax(differentLoggingService.updateDifferentLogging(differentLogging));
    }

    /**
     * 删除日志记录
     */
   // @PreAuthorize("@ss.hasPermi('different:logging:remove')")
    @Log(title = "日志记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/vx/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(differentLoggingService.deleteDifferentLoggingByLogIds(logIds));
    }
    

}
